import {GetUserInfoAPI} from "@/request/api";
export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo: {
            headImg: require("../../assets/img/userImg.f8bbec5e.png"),
            nickName: "游客",
            coin: "---"
        },
        
    },
    mutations: {
        chanUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal
            state.userInfo = payload.userInfo
        },
        initUserInfo(state) {
            state.carTotal = 0
                state.userInfo = {
                    headImg: require("../../assets/img/userImg.f8bbec5e.png"),
                    nickName: "游客",
                    coin: "---"
                }
        },
        
    },
    //CartAPI
    actions: {
        async asyncChanUserInfo({ commit }) {
            let userInfo = await GetUserInfoAPI();
            console.log("userInfo", userInfo);
            commit("chanUserInfo", userInfo.data)
        },
        

    }
}